<template>
  <div>
    <el-col :span="24">
      <el-select v-model="type" placeholder="请选择类型">
        <el-option
          v-for="(item, index) in storeList"
          :key="index"
          :label="item.name"
          :value="item.key"
        >
        </el-option>
      </el-select>

      <el-input
        placeholder="请输入金额"
        v-model="price"
        style="width: 220px; margin-left: 38px"
      ></el-input>

      <el-button @click="confimPrice" style="margin-left: 38px">确定</el-button>
    </el-col>
    <el-table
      :data="ordicarModelList"
      :header-cell-style="{ background: '#F5F5F5', color: '#606266' }"
      border
    >
      <el-table-column
        align="center"
        prop="carModelName"
        label="车型信息"
        min-width="180"
        fixed="left"
      >
      </el-table-column>
      <template v-if="priceAccord == 1">
        <TYTableColumn :price-type="1"></TYTableColumn>
      </template>
      <template v-else-if="priceAccord == 2">
        <XCTableColumn
          v-if="sysPlatformArray.includes('xc')"
          key="xc"
          :price-type="1"
        ></XCTableColumn>
        <HLTableColumn
          v-if="sysPlatformArray.includes('hl')"
          key="hl"
          :price-type="1"
        ></HLTableColumn>
        <WKTableColumn
          v-if="sysPlatformArray.includes('wk')"
          key="wk"
          :price-type="1"
        ></WKTableColumn>
        <ZZCTableColumn
          v-if="sysPlatformArray.includes('zzc')"
          key="zzc"
          :price-type="1"
        ></ZZCTableColumn>
        <ATTableColumn
          v-if="sysPlatformArray.includes('at')"
          key="at"
          :price-type="1"
        ></ATTableColumn>
        <FZTableColumn
          v-if="sysPlatformArray.includes('fz')"
          key="fz"
          :price-type="1"
        ></FZTableColumn>
      </template>
    </el-table>
  </div>
</template>

<script>
import TYTableColumn from "@/views/system/otaPriceUpdate/components/TYTableColumn.vue";
import XCTableColumn from "@/views/system/otaPriceUpdate/components/XCTableColumn.vue";
import HLTableColumn from "@/views/system/otaPriceUpdate/components/HLTableColumn.vue";
import WKTableColumn from "@/views/system/otaPriceUpdate/components/WKTableColumn.vue";
import ZZCTableColumn from "@/views/system/otaPriceUpdate/components/ZZCTableColumn.vue";
import ATTableColumn from "@/views/system/otaPriceUpdate/components/ATTableColumn.vue";
import FZTableColumn from "@/views/system/otaPriceUpdate/components/FZTableColumn.vue";

export default {
  components: {
    TYTableColumn,
    XCTableColumn,
    HLTableColumn,
    WKTableColumn,
    ZZCTableColumn,
    ATTableColumn,
    FZTableColumn,
  },
  props: {
    sysPlatformArray: {
      type: Array,
      default: () => {
        return [];
      },
    },
    carModelList: {
      type: Array,
      default: () => {
        return [];
      },
    },
    priceAccord: {
      type: [String, Number],
      default: 1,
    },
  },
  data() {
    return {
      storeList: [
        /*      { name: "车辆押金", key: "1" },
              { name: "违章押金", key: "2" },*/
        { name: "周内", key: "3" },
        { name: "周末", key: "4" }
      ],
      type:"",
      price:""

    };
  },
  computed: {
    ordicarModelList() {
      const ordicarModelList = _.cloneDeep(this.carModelList).map((item) => {
        item.priceType = 1;
        return item;
      });
      console.log("ordicarModelList", ordicarModelList);
      return ordicarModelList;
    },
  },
  methods: {
    confimPrice() {
      console.log(1111111);
      console.log(this.ordicarModelList);
      console.log(22222222);
      // this.basicList.forEach((ele) => {
      this.ordicarModelList.forEach((ele2) => {
        if (this.type == 1) {
          // alert(ele2.carModelId)
          // this.$set(ele2,'xcWeekdayPrice',this.price)
          // ele2.xcWeekdayPrice2 = this.price
          ele2.flatPriceCarDeposit = this.price;

          ele2.xcCarDeposit = this.price
          ele2.wkCarDeposit = this.price
          ele2.zzcCarDeposit = this.price
          ele2.fzCarDeposit = this.price
          ele2.hlCarDeposit = this.price
          ele2.atCarDeposit = this.price
        }
        if (this.type == 2) {
          ele2.flatPriceViolationDeposit = this.price;

          ele2.xcViolationDeposit = this.price;
          ele2.wkViolationDeposit = this.price;
          ele2.zzcViolationDeposit = this.price;
          ele2.fzViolationDeposit = this.price;
          ele2.hlViolationDeposit = this.price;
          ele2.atViolationDeposit = this.price;
        }
        if (this.type == 3) {
          // ele2.flatPriceWeekdayPrice = this.price;
          ele2.flatPriceWeekdayPrice = this.price

          ele2.wkWeekdayPrice = this.price;
          ele2.zzcWeekdayPrice = this.price;
          ele2.fzWeekdayPrice = this.price;
          ele2.hlWeekdayPrice = this.price;
          ele2.atWeekdayPrice = this.price;
          ele2.xcWeekdayPrice = this.price;

        }
        if (this.type == 4) {
          // ele2.flatPriceWeekdayPrice = this.price;
          ele2.flatPriceWeekendPrice = this.price
          ele2.fzWeekendPrice = this.price;
          ele2.wkWeekendPrice = this.price;
          ele2.zzcWeekendPrice = this.price;
          ele2.hlWeekendPrice = this.price;
          ele2.atWeekendPrice = this.price;
          ele2.xcWeekendPrice = this.price;


        }
      });
      // });
      console.log(22222222);
      console.log(this.basicList);
      console.log(1111111);
    },
    saveTable() {
      return this.ordicarModelList;
    },
  },
  mounted() {},
};
</script>

<style lang="scss" scoped>
</style>
